//
//  TextViewController.m
//  CollectionViewDemo
//
//  Created by apple on 2016/12/13.
//  Copyright © 2016年 liuchengming. All rights reserved.
//

#import "TextViewController.h"
#import "textController.h"

@interface TextViewController ()<UIPageViewControllerDelegate,UIPageViewControllerDataSource>

{
    int curPage;
}

@end

@implementation TextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    self.dataSource = self;
    curPage = 10;
    textController * con = [self.storyboard instantiateViewControllerWithIdentifier:@"text"];
    con.page = curPage;
    [self setViewControllers:@[con] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
}



- (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
    if (curPage == 0)
    {
        return viewController;
    }
    textController * con = [self.storyboard instantiateViewControllerWithIdentifier:@"text"];
    con.page = --curPage;
    return con;
}
- (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
    textController * con = [self.storyboard instantiateViewControllerWithIdentifier:@"text"];
    con.page = ++curPage;
    return con;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
